<template>
	<view class="page-main">
		<liu-slide-questions :dataList="lists" @submit="subData"></liu-slide-questions>
	</view>
</template>

<script>
	import {
		getUserTestPaper,
		addUserTestPaper
	} from '../../api/Teacher.js';
	export default {
		data() {
			return {
				list: [{
					id: '1',
					title: '这是一道单选题',
					problemType: 'SINGLE',
					children: [{
						alias: 'A',
						answer: '选项1',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}, {
						alias: 'B',
						answer: '选项2',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}, {
						alias: 'C',
						answer: '选项3',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}],
				}, {
					id: '2',
					title: '这是一道多选题',
					problemType: 'MULTY',
					children: [{
						alias: 'A',
						answer: '选项1',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}, {
						alias: 'B',
						answer: '选项2',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}, {
						alias: 'C',
						answer: '选项3',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}, {
						alias: 'D',
						answer: '选项4',
						isSelect: 0 //这个是用来回显的字段(0:未选中；1:选中)(可不传)
					}],
				}, {
					id: '3',
					title: '这是一道简答题',
					problemType: 'QUESTION',
					userAnswer: '' //这个是用来回显的字段(可不传)
				}], //问题列表数据
				lists: [],
				req:{
					total:'',//总题数
					correct:'',//答对题数
				}
			}
		},
		onLoad() {
			this.getUserTestPaper();
		},
		methods: {
			//点击提交-问卷
			async subData(data) {
				try {
					const res = await addUserTestPaper(this.req);
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
				console.log('提交的数据：' + JSON.stringify(data))
			},
			/**
			@method 获取问卷题目
			**/
			async getUserTestPaper() {
				try {
					const res = await getUserTestPaper({shop_id:1});
					this.lists = [...res.data.list];
				} catch (err) {
					//TODO handle the exception
					console.log(err);
				}
			},
		}
	}
</script>